package com.mc.code.sysService.Impl;

import com.mc.code.entity.sys.SysMessageManage;
import com.mc.code.mapper.SysMessageMapper;
import com.mc.code.sysService.SysMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class SysMessageServiceImpl implements SysMessageService {
    @Autowired
    private SysMessageMapper sysMessageMapper;


    @Override
    public List<SysMessageManage> findMessageByCondition(String messageState, int currentPage, int pageCount) {
        return sysMessageMapper.findMessageByCondition(messageState,(currentPage - 1) * pageCount,pageCount);
    }

    @Override
    public int getTotalPage(int pageCount,String messageState) {
        Integer total =sysMessageMapper.getTotalPage(messageState);
        return (total - 1) / pageCount + 1;
    }

    @Override
    public SysMessageManage findMessageById(int id) {
        return sysMessageMapper.findMessageById(id);
    }

    @Override
    public int updateState(int id) {
        return sysMessageMapper.updateState(id);
    }

    @Override
    public int replyMessage(SysMessageManage sysMessageManage) {
        return sysMessageMapper.replyMessage(sysMessageManage);
    }
}
